import { defineStore } from 'pinia';
import { pinia } from '../internal/pinia';
import { clientUserDataStore } from '@shared/internal/client';
import { socketDestroy } from '@main/socket';

interface AppState {
  hideContent: boolean;
}

export const useAppStore = defineStore('appStore', {
  state: (): AppState => ({}) as any,
  actions: {
    exitApp() {
      socketDestroy();
      clientUserDataStore.clear();
      window.clientAppSdk.ipc.ipcRenderer.send('rc:exit-app');
    },
    setHideContent(hide: boolean) {
      this.hideContent = hide;
    }
  }
});

export function useAppStoreWithOut() {
  return useAppStore(pinia);
}
